home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / phnf.bst < prev    next >
Lisp/Scheme  |  1992-07-19  |  61KB  |  1,891 lines

  1. % BibTeX styles for various physics journals (27-Feb-1990).
  2. % This file, physics.btx, is based on the file btxbst.doc.
  3.     % Please notify Charles Karney (Karney@Princeton.EDU)
  4.     % of any bugs, improvements, etc.
  5. % Run this file through cpp to get specific versions.  I have written
  6. % a version of cpp within Emacs.  To access it put
  7. %    (autoload 'cpp "tex$bibtex:cpp"        ; Use cpp for BibTeX styles
  8. %          "C preprocessor"
  9. %          t)
  10. % into your .emacs file.  Read in this file with
  11. %    emacs tex$bibtex:physics.btx
  12. % and run cpp with e.g.,
  13. %    M-x cpp <ret> aip <ret>
  14. % Save the resulting file to tex$latex:aip.bst.
  15. % To accomodate the variations we need (in addition to the definitions below)
  16. %    ATIT_SUPPRESS:    do not include the titles of journal articles
  17. %    NAME_INVERT:    put the initials last
  18. %    NAME_UPPER:    convert names to all caps.
  19. %    MONTH_SUPPRESS:    do not include months in journal articles
  20. %    PAREN_DATE:    dates go in parens in journal articles
  21. %    DATE_FIRST:    dates go before page numbers
  22. %    VOLUME_SPACE:    volume set off with space (not colon)
  23. %    NUM_SUPPRESS:    do not include numbers in journal articles
  24. %    BOLD_VOL:    volume numbers in bold face in journal articles
  25. %    BRACKET_NOTE:    notes in brackets
  26. %    PAGE_START_J:    include only starting page for journal articles
  27. %    PAGE_START_O:    include only starting page for other entries
  28. %    PAGE_ABBREV:    abbreviate page to p. and pages to pp.
  29. %    PHYSICS_JOUR:    include abbreviations for Physics journals
  30. %    COMMA_DELIMIT:    use comma (instead of period) to divide a citation
  31. %    NOTE_SUPPRESS:    suppress the note
  32. %    MAX_NAMES:    max number of authors before using et al (0 = infinity)
  33. %    MIN_NAMES:    number of authors to list with et al.
  34. %    EDIT_VAR:    use "edited by ..." instead of "..., editors"
  35. %    RMP_LABELS:    create RMP-style labels
  36. %    KEY_CITE:    use key as label
  37. %    NAMED_REFS:    use (Smith, 1988) style of citations
  38. %    CSC_NAMES:    names set in caps and small caps
  39. %    JOUR_DEEMPH:    don't emphasize journal name
  40. %    ETAL_EMPH:    emphasize et al.
  41. %    ALT_INCOLL    alternate ordering of fields in incollections
  42. % These are all boolean (0 or 1) except for MAX_NAMES and MIN_NAMES.
  43. % These need to satisfy 0 <= MIN_NAMES <= MAX_NAMES.
  44. % The rule here is that if all these are defined to be zero, we revert to
  45. % the standard styles.  For that reason we initialize them all to 0.
  46. % These are the original macros
  47.     % For Nuclear Fusion
  48.     % see Nuclear Fusion Vol. 28, No. 2 (1988),
  49.     % "Announcement [of] Guidelines for Bibliographical Citations"
  50. % same as AIP except for 0, 0, 0 and 
  51. %  0 and 0 set to use only three names if there are 
  52. %  6 or more.  Also, no 0, and use 0 and 0.
  53. % There are still some nits to be picked (years in parentheses for
  54. % other than journals, volumes having Vol. before them and pages not
  55. % having p.)
  56. % This is the start of btxbst.doc
  57. % BibTeX `plain' family
  58.     % version 0.99b for BibTeX versions 0.99a or later, LaTeX version 2.09.
  59.     % Copyright (C) 1985, all rights reserved.
  60.     % Copying of this file is authorized only if either
  61.     % (1) you make absolutely no changes to your copy, including name, or
  62.     % (2) if you do make changes, you name it something other than
  63.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  64.     % This restriction helps ensure that all standard styles are identical.
  65.     % The file btxbst.doc has the documentation for this style.
  66. % Please notify Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU) of any bugs in
  67. % these standard styles or in this documentation file.
  68. %
  69. % This is file btxbxt.doc; it helps document bibliography styles,
  70. % and is also a template file that you can use to make
  71. % several different style files, if you have access to a C preprocessor.
  72. % For example, the standard styles were made by doing something like
  73. %    cpp -P -DPLAIN btxbst.doc plain.txt
  74. %    cpp -P -DUNSRT btxbst.doc unsrt.txt
  75. %    cpp -P -DALPHA btxbst.doc alpha.txt
  76. %    cpp -P -DABBRV btxbst.doc abbrv.txt
  77. % and then renaming after removing unwanted comments and blank lines.
  78. % If you don't have access,
  79. % you can edit this file by hand to imitate the preprocessor,
  80. % with the following explanation of the C preprocessor constructs used here.
  81. %
  82. % The output of the preprocessor is the same as the input, except that certain
  83. % lines will be excluded (and some blank lines will be added).  The sequence
  84. %    #if VAR
  85. %        lines to be included when VAR is not zero
  86. %    #else
  87. %        lines to be included when VAR is zero
  88. %    #endif
  89. % (with the #-signs appearing in column 1) means that one set or the other of
  90. % the lines are to be included depending on the value of VAR.
  91. % The #else part is optional.  Comments can be added after #else and #endif.
  92. % Variables can be set by
  93. %    #define VAR value
  94. % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
  95. % to see if it has none.
  96. % Another #if form used in this file is #if !VAR, which includes the lines
  97. % after the #if only if VAR is zero.
  98. %
  99. % Convention: Use all uppercase identifiers for these preprocessor variables
  100. % so you can spot them easily
  101. %
  102. % The command line to the preprocessor should define one of PLAIN, UNSRT, ALPHA
  103. % or ABBRV (though PLAIN will be used by default if none is given),
  104. % and the following lines will set various boolean variables to control the
  105. % various lines that are chosen from the rest of the file.
  106. % Each boolean variable should be set true (1) or false (0) in each style.
  107. % Here are the current variables, and their meanings:
  108. %    0:    an alphabetic label is used (if false then a numeric
  109. %                label is used)
  110. %    0:        the entries should be sorted by label (if nonnumeric)
  111. %                and other info, like authors (if false, then
  112. %                entries remain in order of occurrence)
  113. %    0:    the authors, editors, etc., get the full names as
  114. %                given in the bibliography file (if false, the first
  115. %                names become initials)
  116. %    1:    titles of non-"books" (e.g., articles) should be
  117. %                converted to lower-case, except the first letter or
  118. %                first letter after a colon
  119. %                (if false then they appear as in the database)
  120. %    0:    months are spelled out in full (if false, then
  121. %                they're abbreviated)
  122. %    0:    macro journal names are spelled out in full
  123. %                (if false then they are abbreviated, currently
  124. %                as they appear in ACM publications)
  125. %#        define PLAIN 1
  126. %
  127. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  128. %    in "A Handbook for Scholars".  Book-like titles are italicized
  129. %    (emphasized) and non-book titles are converted to sentence
  130. %    capitilization (and not enclosed in quotes).
  131. %    This file outputs a \newblock between major blocks of an entry
  132. %    (the name \newblock is analogous to the names \newline and \newpage)
  133. %    so that the user can obtain an "open" format, which has a line break
  134. %    before each block and lines after the first are indented within blocks,
  135. %    by giving the optional \documentstyle argument `openbib';
  136. %    The default is the "closed" format---blocks runs together.
  137. %
  138. %   Citation alphabetic label format:
  139. %        [Knu73] for single author (or editor or key)
  140. %        [AHU83] (first letters of last names) for multiple authors
  141. %
  142. %   Citation label numberic format:
  143. %        [number]
  144. %
  145. %   Reference list ordering for sorted, alphabetic lables:
  146. %        alphabetical by citation label, then by author(s) or whatever
  147. %        passes for author in the absence of one, then by year,
  148. %        then title
  149. %
  150. %   Reference list ordering for sorted, numeric lables:
  151. %        alphabetical by author(s) or whatever passes
  152. %        for author in the absence of one, then by year, then title
  153. %
  154. %   Reference list ordering for unsorted:
  155. %        by the order cited in the text
  156. %
  157. %   History
  158. %   12/16/84    (HWT)    Original `plain' version, by Howard Trickey.
  159. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  160. %    2/16/85    (OP)    Changes based on LL's comments, Oren Patashnik.
  161. %    2/17/85    (HWT)    Template file and other standard styles made.
  162. %    3/28/85    (OP)    First release, version 0.98b for BibTeX 0.98f.
  163. %    5/ 9/85    (OP)    Version 0.98c for BibTeX 0.98i:
  164. %            fixed Theoretical Computer Science macro name;
  165. %            fixed the format.vol.num.pages function.
  166. %    1/24/88    (OP)    Version 0.99a for BibTeX 0.99a, main changes:
  167. %            assignment operator (:=) arguments reversed;
  168. %            the preamble$ function outputs the database PREAMBLE;
  169. %            entry.max$ and global.max$ (built-in) variables replace
  170. %            entry.string.max and global.string.max functions;
  171. %            alphabetizing by year then title, not just title;
  172. %            many unnecessary ties removed; \it ==> \em;
  173. %            the `alpha' style uses a superscripted `+' instead of a
  174. %            `*' for unnamed names in constructing the label;
  175. %            the `abbrv' style now uses "Mar." and "Sept.";
  176. %            the functions calc.label and presort now look at just
  177. %            the fields they're supposed to;
  178. %            BOOKLET, MASTERSTHESIS, TECHREPORT use nonbook titles;
  179. %            INBOOK and INCOLLECTION take an optional type (e.g.
  180. %            type = "Section"), overriding the default "chapter";
  181. %            BOOK, INBOOK, INCOLLECTION, and PROCEEDINGS now allow
  182. %            either volume or number, not just volume;
  183. %            INCOLLECTION now allows an edition and series field;
  184. %            PROCEEDINGS and INPROCEEDINGS now use the address field
  185. %            to tell where a conference was held;
  186. %            INPROCEEDINGS and PROCEEDINGS now allow either volume
  187. %            or number, and also a series field;
  188. %            MASTERSTHESIS and PHDTHESIS accept types other than
  189. %            "Master's thesis" and "PhD thesis";
  190. %            UNPUBLISHED now outputs, in one block, note then date;
  191. %            MANUAL now prints out the organization in
  192. %            the first block if the author field is empty;
  193. %            MISC can't be empty---it requires some optional field.
  194. %    3/23/88    (OP)    Version 0.99b for BibTeX 0.99c---changed the three
  195. %            erroneous occurrences of `cite ' to `cite$ '; this
  196. %            change didn't affect the four standard styles, so the
  197. %            0.99a versions of those styles are still current.
  198. %
  199. % The ENTRY declaration
  200. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  201. %   but no fullauthor or editors fields because BibTeX does name handling.
  202. %   The annote field is commented out here because this family doesn't
  203. %   include an annotated bibliography style.  And in addition to the fields
  204. %   listed here, BibTeX has a built-in crossref field, explained later.
  205. ENTRY
  206. % Fields:
  207.   { address
  208. %        Usually the address of a publisher or other type of organization.
  209. %        Put information in this field only if it helps the reader find the
  210. %        thing---for example you should omit the address of a major
  211. %        publisher entirely.  For a PROCEEDINGS or an INPROCEEDINGS,
  212. %        however, it's the address of the conference; for those two entry
  213. %        types, include the publisher's or organization's address, if
  214. %        necessary, in the publisher or organization field.
  215. %    annote
  216. %        Long annotation---for annotated bibliographies (begins sentence).
  217.     author
  218. %        Name(s) of author(s), in BibTeX name format.
  219.     booktitle
  220. %        Book title when the thing being referenced isn't the whole book.
  221. %        For book entries, the title field should be used instead.
  222.     chapter
  223. %        Chapter (or section or whatever) number.
  224.     edition
  225. %        Edition of a book---should be an ordinal (e.g., "Second").
  226.     editor
  227. %        Name(s) of editor(s), in BibTeX name format.
  228. %        If there is also an author field, then the editor field should be
  229. %        for the book or collection that the work appears in.
  230.     howpublished
  231. %         How something strange has been published (begins sentence).
  232.     institution
  233. %        Sponsoring institution of a technical report.
  234.     journal
  235. %        Journal name (macros are provided for many).
  236.     key
  237. %        Alphabetizing, labeling, and cross-referencing key
  238. %        (needed when an entry has no author or editor).
  239.     month
  240. %        Month (macros are provided).
  241.     note
  242. %        To help the reader find a reference (begins sentence).
  243.     number
  244. %        Number of a journal or technical report, or of a work in a series.
  245.     organization
  246. %        Organization sponsoring a conference (or publishing a manual); if
  247. %        the editor (or author) is empty, and if the organization produces
  248. %        an awkward label or cross reference, you should put appropriately
  249. %        condensed organization information in the key field as well.
  250.     pages
  251. %        Page number or numbers (use `--' to separate a range, use `+'
  252. %        to indicate pages following that don't form a simple range).
  253.     publisher
  254. %        Publisher name.
  255.     school
  256. %        School name (for theses).
  257.     series
  258. %        The name of a series or set of books.
  259. %        An individual book will will also have it's own title.
  260.     title
  261. %        The title of the thing you're referred to.
  262.     type
  263. %        Type of a Techreport (e.g., "Research Note") to be used instead of
  264. %        the default "Technical Report"; or, similarly, the type of a
  265. %        thesis; or of a part of a book.
  266.     volume
  267. %        The volume number of a journal or multivolume work.
  268.     year
  269. %        The year should contain only numerals (technically, it should end
  270. %        with four numerals, after purification; doesn't a begin sentence).
  271.   }
  272. % There are no integer entry variables
  273.   {}
  274. % These string entry variables are used to form the citation label.
  275. % In a storage pinch, sort.label can be easily computed on the fly.
  276.   { label }
  277. % Each entry function starts by calling output.bibitem, to write the
  278. % \bibitem and its arguments to the .BBL file.  Then the various fields
  279. % are formatted and printed by output or output.check.  Those functions
  280. % handle the writing of separators (commas, periods, \newblock's),
  281. % taking care not to do so when they are passed a null string.
  282. % Finally, fin.entry is called to add the final period and finish the
  283. % entry.
  284. %
  285. % A bibliographic reference is formatted into a number of `blocks':
  286. % in the open format, a block begins on a new line and subsequent
  287. % lines of the block are indented.  A block may contain more than
  288. % one sentence (well, not a grammatical sentence, but something to
  289. % be ended with a sentence ending period).  The entry functions should
  290. % call new.block whenever a block other than the first is about to be
  291. % started.  They should call new.sentence whenever a new sentence is
  292. % to be started.  The output functions will ensure that if two
  293. % new.sentence's occur without any non-null string being output between
  294. % them then there won't be two periods output.  Similarly for two
  295. % successive new.block's.
  296. %
  297. % The output routines don't write their argument immediately.
  298. % Instead, by convention, that argument is saved on the stack to be
  299. % output next time (when we'll know what separator needs to come
  300. % after it).  Meanwhile, the output routine has to pop the pending
  301. % output off the stack, append any needed separator, and write it.
  302. %
  303. % To tell which separator is needed, we maintain an output.state.
  304. % It will be one of these values:
  305. %    before.all        just after the \bibitem
  306. %    mid.sentence        in the middle of a sentence: comma needed
  307. %                    if more sentence is output
  308. %    after.sentence        just after a sentence: period needed
  309. %    after.block        just after a block (and sentence):
  310. %                    period and \newblock needed.
  311. % Note: These styles don't use after.sentence
  312. %
  313. % VAR: output.state : INTEGER        -- state variable for output
  314. %
  315. % The output.nonnull function saves its argument (assumed to be nonnull)
  316. % on the stack, and writes the old saved value followed by any needed
  317. % separator.  The ordering of the tests is decreasing frequency of
  318. % occurrence.
  319. %
  320. % output.nonnull(s) ==
  321. %  BEGIN
  322. %    s := argument on stack
  323. %    if output.state = mid.sentence then
  324. %        write$(pop() * ", ")
  325. %          -- "pop" isn't a function: just use stack top
  326. %    else
  327. %        if output.state = after.block then
  328. %        write$(add.period$(pop()))
  329. %        newline$
  330. %        write$("\newblock ")
  331. %        else
  332. %        if output.state = before.all then
  333. %            write$(pop())
  334. %        else        -- output.state should be after.sentence
  335. %            write$(add.period$(pop()) * " ")
  336. %        fi
  337. %        fi
  338. %        output.state := mid.sentence
  339. %    fi
  340. %    push s on stack
  341. %  END
  342. %
  343. % The output function calls output.nonnull if its argument is non-empty;
  344. % its argument may be a missing field (thus, not necessarily a string)
  345. %
  346. % output(s) ==
  347. %  BEGIN
  348. %    if not empty$(s) then output.nonnull(s)
  349. %    fi
  350. %  END
  351. %
  352. % The output.check function is the same as the output function except that, if
  353. % necessary, output.check warns the user that the t field shouldn't be empty
  354. % (this is because it probably won't be a good reference without the field;
  355. % the entry functions try to make the formatting look reasonable even when
  356. % such fields are empty).
  357. %
  358. % output.check(s,t) ==
  359. %  BEGIN
  360. %    if empty$(s) then
  361. %        warning$("empty " * t * " in " * cite$)
  362. %    else output.nonnull(s)
  363. %    fi
  364. %  END
  365. %
  366. % The output.bibitem function writes the \bibitem for the current entry
  367. % (the label should already have been set up), and sets up the separator
  368. % state for the output functions.  And, it leaves a string on the stack
  369. % as per the output convention.
  370. %
  371. % output.bibitem ==
  372. %  BEGIN
  373. %    newline$
  374. %    write$("\bibitem[")    % for alphabetic labels,
  375. %    write$(label)        % these three lines
  376. %    write$("]{")        % are used
  377. %    write$("\bibitem{")        % this line for numeric labels
  378. %    write$(cite$)
  379. %    write$("}")
  380. %    push "" on stack
  381. %    output.state := before.all
  382. %  END
  383. %
  384. % The fin.entry function finishes off an entry by adding a period to the
  385. % string remaining on the stack.  If the state is still before.all
  386. % then nothing was produced for this entry, so the result will look bad,
  387. % but the user deserves it. (We don't omit the whole entry because the
  388. % entry was cited, and a bibitem is needed to define the citation label.)
  389. %
  390. % fin.entry ==
  391. %  BEGIN
  392. %    write$(add.period$(pop()))
  393. %    newline$
  394. %  END
  395. %
  396. % The new.block function prepares for a new block to be output, and
  397. % new.sentence prepares for a new sentence.
  398. %
  399. % new.block ==
  400. %  BEGIN
  401. %    if output.state <> before.all then
  402. %        output.state := after.block
  403. %    fi
  404. %  END
  405. %
  406. % new.sentence ==
  407. %  BEGIN
  408. %    if output.state <> after.block then
  409. %        if output.state <> before.all then
  410. %        output.state :=  after.sentence
  411. %        fi
  412. %    fi
  413. %  END
  414. %
  415. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  416. FUNCTION {init.state.consts}
  417. { #0 'before.all :=
  418.   #1 'mid.sentence :=
  419.   #2 'after.sentence :=
  420.   #3 'after.block :=
  421. }
  422. % the variables s and t are temporary string holders
  423. STRINGS { s t }
  424. FUNCTION {output.nonnull}
  425. { 's :=
  426.   output.state mid.sentence =
  427.     { ", " * write$ }
  428.     { output.state after.block =
  429.     { "," * write$
  430.       newline$
  431.       "\newblock " write$
  432.     }
  433.     { output.state before.all =
  434.         'write$
  435.         { add.period$ " " * write$ }
  436.       if$
  437.     }
  438.       if$
  439.       mid.sentence 'output.state :=
  440.     }
  441.   if$
  442.   s
  443. }
  444. FUNCTION {output}
  445. { duplicate$ empty$
  446.     'pop$
  447.     'output.nonnull
  448.   if$
  449. }
  450. FUNCTION {output.check}
  451. { 't :=
  452.   duplicate$ empty$
  453.     { pop$ "empty " t * " in " * cite$ * warning$ }
  454.     'output.nonnull
  455.   if$
  456. }
  457. FUNCTION {output.bibitem}
  458. { newline$
  459.   "\bibitem{" write$
  460.   cite$ write$
  461.   "}" write$
  462.   newline$
  463.   ""
  464.   before.all 'output.state :=
  465. }
  466. % This function finishes all entries.
  467. FUNCTION {fin.entry}
  468. { add.period$
  469.   write$
  470.   newline$
  471. }
  472. FUNCTION {new.block}
  473. { output.state before.all =
  474.     'skip$
  475.     { after.block 'output.state := }
  476.   if$
  477. }
  478. FUNCTION {new.sentence}
  479. { skip$
  480. }
  481. % These three functions pop one or two (integer) arguments from the stack
  482. % and push a single one, either 0 or 1.
  483. % The 'skip$ in the `and' and `or' functions are used because
  484. % the corresponding if$ would be idempotent
  485. FUNCTION {not}
  486. {   { #0 }
  487.     { #1 }
  488.   if$
  489. }
  490. FUNCTION {and}
  491. {   'skip$
  492.     { pop$ #0 }
  493.   if$
  494. }
  495. FUNCTION {or}
  496. {   { pop$ #1 }
  497.     'skip$
  498.   if$
  499. }
  500. % Sometimes we begin a new block only if the block will be big enough.  The
  501. % new.block.checka function issues a new.block if its argument is nonempty;
  502. % new.block.checkb does the same if either of its TWO arguments is nonempty.
  503. FUNCTION {new.block.checka}
  504. { empty$
  505.     'skip$
  506.     'new.block
  507.   if$
  508. }
  509. FUNCTION {new.block.checkb}
  510. { empty$
  511.   swap$ empty$
  512.   and
  513.     'skip$
  514.     'new.block
  515.   if$
  516. }
  517. % The new.sentence.check functions are analogous.
  518. FUNCTION {new.sentence.checka}
  519. { empty$
  520.     'skip$
  521.     'new.sentence
  522.   if$
  523. }
  524. FUNCTION {new.sentence.checkb}
  525. { empty$
  526.   swap$ empty$
  527.   and
  528.     'skip$
  529.     'new.sentence
  530.   if$
  531. }
  532. % Here are some functions for formatting chunks of an entry.
  533. % By convention they either produce a string that can be followed by
  534. % a comma or period (using add.period$, so it is OK to end in a period),
  535. % or they produce the null string.
  536. %
  537. % A useful utility is the field.or.null function, which checks if the
  538. % argument is the result of pushing a `missing' field (one for which no
  539. % assignment was made when the current entry was read in from the database)
  540. % or the result of pushing a string having no non-white-space characters.
  541. % It returns the null string if so, otherwise it returns the field string.
  542. % Its main (but not only) purpose is to guarantee that what's left on the
  543. % stack is a string rather than a missing field.
  544. %
  545. % field.or.null(s) ==
  546. %  BEGIN
  547. %    if empty$(s) then return ""
  548. %    else return s
  549. %  END
  550. %
  551. % Another helper function is emphasize, which returns the argument emphazised,
  552. % if that is non-empty, otherwise it returns the null string.  Italic
  553. % corrections aren't used, so this function should be used when punctation
  554. % will follow the result.
  555. %
  556. % emphasize(s) ==
  557. %  BEGIN
  558. %    if empty$(s) then return ""
  559. %    else return "{\em " * s * "}"
  560. %
  561. % The format.names function formats the argument (which should be in
  562. % BibTeX name format) into "First Von Last, Junior", separated by commas
  563. % and with an "and" before the last (but ending with "et~al." if the last
  564. % of multiple authors is "others").  This function's argument should always
  565. % contain at least one name.
  566. %
  567. % VAR: nameptr, namesleft, numnames: INTEGER
  568. % pseudoVAR: nameresult: STRING        (it's what's accumulated on the stack)
  569. %
  570. % format.names(s) ==
  571. %  BEGIN
  572. %    nameptr := 1
  573. %    numnames := num.names$(s)
  574. %    namesleft := numnames
  575. %    while namesleft > 0
  576. %      do
  577. %                % for full names:
  578. %        t := format.name$(s, nameptr, "{ff~}{vv~}{ll}{, jj}")
  579. %                % for abbreviated first names:
  580. %        t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
  581. %        if nameptr > 1 then
  582. %        if namesleft > 1 then nameresult := nameresult * ", " * t
  583. %        else if numnames > 2
  584. %               then nameresult := nameresult * ","
  585. %             fi
  586. %             if t = "others"
  587. %               then nameresult := nameresult * " et~al."
  588. %               else nameresult := nameresult * " and " * t
  589. %             fi
  590. %        fi
  591. %        else nameresult := t
  592. %        fi
  593. %        nameptr := nameptr + 1
  594. %        namesleft := namesleft - 1
  595. %      od
  596. %    return nameresult
  597. %  END
  598. %
  599. % The format.authors function returns the result of format.names(author)
  600. % if the author is present, or else it returns the null string
  601. %
  602. % format.authors ==
  603. %  BEGIN
  604. %    if empty$(author) then return ""
  605. %    else return format.names(author)
  606. %    fi
  607. %  END
  608. %
  609. % Format.editors is like format.authors, but it uses the editor field,
  610. % and appends ", editor" or ", editors"
  611. %
  612. % format.editors ==
  613. %  BEGIN
  614. %    if empty$(editor) then return ""
  615. %    else
  616. %        if num.names$(editor) > 1 then
  617. %        return format.names(editor) * ", editors"
  618. %        else
  619. %        return format.names(editor) * ", editor"
  620. %        fi
  621. %    fi
  622. %  END
  623. %
  624. % Other formatting functions are similar, so no "comment version" will be
  625. % given for them.
  626. %
  627. % The `pop$' in this function gets rid of the duplicate `empty' value and
  628. % the `skip$' returns the duplicate field value
  629. FUNCTION {field.or.null}
  630. { duplicate$ empty$
  631.     { pop$ "" }
  632.     'skip$
  633.   if$
  634. }
  635. FUNCTION {emphasize}
  636. { duplicate$ empty$
  637.     { pop$ "" }
  638.     { "{\em " swap$ * "}" * }
  639.   if$
  640. }
  641. FUNCTION {embolden}
  642. { duplicate$ empty$
  643.     { pop$ "" }
  644.     { "{\bf " swap$ * "}" * }
  645.   if$
  646. }
  647. FUNCTION {paren}
  648. { duplicate$ empty$
  649.     { pop$ "" }
  650.     { "(" swap$ * ")" * }
  651.   if$
  652. }
  653. INTEGERS { nameptr namesleft numnames }
  654. INTEGERS { etal }
  655. FUNCTION {format.names}
  656. { 's :=
  657.   #1 'nameptr :=
  658.   s num.names$ 'numnames :=
  659.   numnames #5 >
  660.   s numnames "{ll}" format.name$ "others" = numnames #3 > and
  661.   or 'etal :=
  662.   etal
  663.     { #3 #1 + 'namesleft := }
  664.     { numnames 'namesleft := }
  665.   if$
  666.     { namesleft #0 > }
  667.     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=   % last name first
  668.       t "others" =
  669.     'skip$
  670.     { t "u" change.case$ 't := }
  671.       if$
  672.       nameptr #1 >
  673.     { namesleft #1 >
  674.         { ", " * t * }
  675.         { nameptr #2 >
  676.         { "," * }
  677.         'skip$
  678.           if$
  679.           t "others" =
  680.           etal or
  681.         { " et~al." * }
  682.         { " and " * t * }
  683.           if$
  684.         }
  685.       if$
  686.     }
  687.     't
  688.       if$
  689.       nameptr #1 + 'nameptr :=
  690.       namesleft #1 - 'namesleft :=
  691.     }
  692.   while$
  693. }
  694. FUNCTION {format.authors}
  695. { author empty$
  696.     { "" }
  697.     { author format.names }
  698.   if$
  699. }
  700. FUNCTION {format.editors}
  701. { editor empty$
  702.     { "" }
  703.     { editor format.names
  704.       editor num.names$ #1 >
  705.     { ", editors" * }
  706.     { ", editor" * }
  707.       if$
  708.     }
  709.   if$
  710. }
  711. % The format.title function is used for non-book-like titles.
  712. % For most styles we convert to lowercase (except for the very first letter,
  713. % and except for the first one after a colon (followed by whitespace)),
  714. % and hope the user has brace-surrounded words that need to stay capitilized;
  715. % for some styles, however, we leave it as it is in the database.
  716. FUNCTION {format.title}
  717. { title empty$
  718.     { "" }
  719.     { title "t" change.case$ }
  720.   if$
  721. }
  722. % By default, BibTeX sets the global integer variable global.max$ to the BibTeX
  723. % constant glob_str_size, the maximum length of a global string variable.
  724. % Analogously, BibTeX sets the global integer variable entry.max$ to
  725. % ent_str_size, the maximum length of an entry string variable.
  726. % The style designer may change these if necessary (but this is unlikely)
  727. % The n.dashify function makes each single `-' in a string a double `--'
  728. % if it's not already
  729. %
  730. % pseudoVAR: pageresult: STRING        (it's what's accumulated on the stack)
  731. %
  732. % n.dashify(s) ==
  733. %  BEGIN
  734. %    t := s
  735. %    pageresult := ""
  736. %    while (not empty$(t))
  737. %      do
  738. %        if (first character of t = "-")
  739. %          then
  740. %        if (next character isn't)
  741. %          then
  742. %            pageresult := pageresult * "--"
  743. %            t := t with the "-" removed
  744. %          else
  745. %            while (first character of t = "-")
  746. %              do
  747. %            pageresult := pageresult * "-"
  748. %            t := t with the "-" removed
  749. %              od
  750. %        fi
  751. %          else
  752. %        pageresult := pageresult * the first character
  753. %        t := t with the first character removed
  754. %        fi
  755. %      od
  756. %    return pageresult
  757. %  END
  758. FUNCTION {n.dashify}
  759. { 't :=
  760.   ""
  761.     { t empty$ not }
  762.     { t #1 #1 substring$ "-" =
  763.     { t #1 #2 substring$ "--" = not
  764.         { "--" *
  765.           t #2 global.max$ substring$ 't :=
  766.         }
  767.         {   { t #1 #1 substring$ "-" = }
  768.         { "-" *
  769.           t #2 global.max$ substring$ 't :=
  770.         }
  771.           while$
  772.         }
  773.       if$
  774.     }
  775.     { t #1 #1 substring$ *
  776.       t #2 global.max$ substring$ 't :=
  777.     }
  778.       if$
  779.     }
  780.   while$
  781. }
  782. FUNCTION {first.page}
  783. { 't :=
  784.   ""
  785.     {  t empty$ not t #1 #1 substring$ "-" = not and }
  786.     { t #1 #1 substring$ *
  787.       t #2 global.max$ substring$ 't :=
  788.     }
  789.   while$
  790. }
  791. % The format.date function is for the month and year, but we give a warning if
  792. % there's an empty year but the month is there, and we return the empty string
  793. % if they're both empty.
  794. FUNCTION {format.date}
  795. { year empty$
  796.     { "" }
  797.     'year
  798.   if$
  799. }
  800. % The format.btitle is for formatting the title field when it is a book-like
  801. % entry---the style used here keeps it in uppers-and-lowers and emphasizes it.
  802. FUNCTION {format.btitle}
  803. { title emphasize
  804. }
  805. % For several functions we'll need to connect two strings with a
  806. % tie (~) if the second one isn't very long (fewer than 3 characters).
  807. % The tie.or.space.connect function does that.  It concatenates the two
  808. % strings on top of the stack, along with either a tie or space between
  809. % them, and puts this concatenation back onto the stack:
  810. %
  811. % tie.or.space.connect(str1,str2) ==
  812. %    BEGIN
  813. %    if text.length$(str2) < 3
  814. %      then return the concatenation of str1, "~", and str2
  815. %      else return the concatenation of str1, " ", and str2
  816. %    END
  817. FUNCTION {tie.or.space.connect}
  818. { duplicate$ text.length$ #3 <
  819.     { "~" }
  820.     { " " }
  821.   if$
  822.   swap$ * *
  823. }
  824. % The either.or.check function complains if both fields or an either-or pair
  825. % are nonempty.
  826. %
  827. % either.or.check(t,s) ==
  828. %  BEGIN
  829. %    if empty$(s) then
  830. %        warning$(can't use both " * t * " fields in " * cite$)
  831. %    fi
  832. %  END
  833. FUNCTION {either.or.check}
  834. { empty$
  835.     'pop$
  836.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  837.   if$
  838. }
  839. % The format.bvolume function is for formatting the volume and perhaps
  840. % series name of a multivolume work.  If both a volume and a series field
  841. % are there, we assume the series field is the title of the whole multivolume
  842. % work (the title field should be the title of the thing being referred to),
  843. % and we add an "of <series>".  This function is called in mid-sentence.
  844. FUNCTION {format.bvolume}
  845. { volume empty$
  846.     { "" }
  847.     { "volume" volume tie.or.space.connect
  848.       series empty$
  849.     'skip$
  850.     { " of " * series emphasize * }
  851.       if$
  852.       "volume and number" number either.or.check
  853.     }
  854.   if$
  855. }
  856. % The format.number.series function is for formatting the series name
  857. % and perhaps number of a work in a series.  This function is similar to
  858. % format.bvolume, although for this one the series must exist (and the
  859. % volume must not exist).  If the number field is empty we output either
  860. % the series field unchanged if it exists or else the null string.
  861. % If both the number and series fields are there we assume the series field
  862. % gives the name of the whole series (the title field should be the title
  863. % of the work being one referred to), and we add an "in <series>".
  864. % We capitilize Number when this function is used at the beginning of a block.
  865. FUNCTION {format.number.series}
  866. { volume empty$
  867.     { number empty$
  868.     { series field.or.null }
  869.     { output.state mid.sentence =
  870.         { "number" }
  871.         { "Number" }
  872.       if$
  873.       number tie.or.space.connect
  874.       series empty$
  875.         { "there's a number but no series in " cite$ * warning$ }
  876.         { " in " * series * }
  877.       if$
  878.     }
  879.       if$
  880.     }
  881.     { "" }
  882.   if$
  883. }
  884. % The format.edition function appends " edition" to the edition, if present.
  885. % We lowercase the edition (it should be something like "Third"), because
  886. % this doesn't start a sentence.
  887. FUNCTION {format.edition}
  888. { edition empty$
  889.     { "" }
  890.     { output.state mid.sentence =
  891.     { edition "l" change.case$ " edition" * }
  892.     { edition "t" change.case$ " edition" * }
  893.       if$
  894.     }
  895.   if$
  896. }
  897. % The format.pages function is used for formatting a page range in a book
  898. % (and in rare circumstances, an article).
  899. %
  900. % The multi.page.check function examines the page field for a "-" or "," or "+"
  901. % so that format.pages can use "page" instead of "pages" if none exists.
  902. % Note: global.max$ here means "take the rest of the string"
  903. %
  904. % VAR: multiresult: INTEGER    (actually, a boolean)
  905. %
  906. % multi.page.check(s) ==
  907. %  BEGIN
  908. %    t := s
  909. %    multiresult := false
  910. %    while ((not multiresult) and (not empty$(t)))
  911. %      do
  912. %        if (first character of t = "-" or "," or "+")
  913. %          then multiresult := true
  914. %          else t := t with the first character removed
  915. %        fi
  916. %      od
  917. %    return multiresult
  918. %  END
  919. INTEGERS { multiresult }
  920. FUNCTION {multi.page.check}
  921. { 't :=
  922.   #0 'multiresult :=
  923.     { multiresult not
  924.       t empty$ not
  925.       and
  926.     }
  927.     { t #1 #1 substring$
  928.       duplicate$ "-" =
  929.       swap$ duplicate$ "," =
  930.       swap$ "+" =
  931.       or or
  932.     { #1 'multiresult := }
  933.     { t #2 global.max$ substring$ 't := }
  934.       if$
  935.     }
  936.   while$
  937.   multiresult
  938. }
  939. % This function doesn't begin a sentence so "pages" isn't capitalized.
  940. % Other functions that use this should keep that in mind.
  941. FUNCTION {format.pages}
  942. { pages empty$
  943.     { "" }
  944.     { pages multi.page.check
  945.     { "pp." pages n.dashify tie.or.space.connect }
  946.     { "p." pages tie.or.space.connect }
  947.       if$
  948.     }
  949.   if$
  950. }
  951. FUNCTION {format.pages.a}
  952. { pages empty$
  953.     { "" }
  954.     { "p." pages first.page tie.or.space.connect }
  955.   if$
  956. }
  957. % The format.vol.num.pages function is for the volume, number, and page range
  958. % of a journal article.  We use the format:  vol(number):pages, with some
  959. % variations for empty fields.  This doesn't begin a sentence.
  960. FUNCTION {format.vol.num.pages}
  961. { volume field.or.null embolden
  962.   " " swap$ * *
  963.   format.date empty$
  964.     'skip$
  965.     { duplicate$ empty$
  966.     { pop$ format.date paren }
  967.         { " " * format.date paren * }
  968.       if$
  969.     }
  970.   if$
  971.   pages empty$
  972.     'skip$
  973.     { duplicate$ empty$
  974.     { pop$ format.pages.a }
  975.     { " " * pages first.page *}
  976.       if$
  977.     }
  978.   if$
  979. }
  980. % The format.chapter.pages, if the chapter is present, puts whatever is in the
  981. % type field (or else "chapter" if type is empty) in front of a chapter number.
  982. % It then appends the pages, if present.  This doesn't begin a sentence.
  983. FUNCTION {format.chapter.pages}
  984. { chapter empty$
  985.     'format.pages
  986.     { type empty$
  987.     { "chapter" }
  988.     { type "l" change.case$ }
  989.       if$
  990.       chapter tie.or.space.connect
  991.       pages empty$
  992.     'skip$
  993.     { ", " * format.pages * }
  994.       if$
  995.     }
  996.   if$
  997. }
  998. % The format.in.ed.booktitle function is used for starting out a sentence
  999. % that begins "In <booktitle>", putting an editor before the title if one
  1000. % exists.
  1001. FUNCTION {format.in.ed.booktitle}
  1002. { booktitle empty$
  1003.     { "" }
  1004.     { editor empty$
  1005.     { "in " booktitle emphasize * }
  1006.     { "in " format.editors * ", " * booktitle emphasize * }
  1007.       if$
  1008.     }
  1009.   if$
  1010. }
  1011. % The function empty.misc.check complains if all six fields are empty, and
  1012. % if there's been no sorting or alphabetic-label complaint.
  1013. FUNCTION {empty.misc.check}
  1014. { author empty$ title empty$ howpublished empty$
  1015.   month empty$ year empty$ note empty$
  1016.   and and and and and
  1017.     { "all relevant fields are empty in " cite$ * warning$ }
  1018.     'skip$
  1019.   if$
  1020. }
  1021. % The function format.thesis.type returns either the (case-changed) type field,
  1022. % if it is defined, or else the default string already on the stack
  1023. % (like "Master's thesis" or "PhD thesis").
  1024. FUNCTION {format.thesis.type}
  1025. { type empty$
  1026.     'skip$
  1027.     { pop$
  1028.       type "t" change.case$
  1029.     }
  1030.   if$
  1031. }
  1032. % The function format.tr.number makes a string starting with "Technical Report"
  1033. % (or type, if that field is defined), followed by the number if there is one;
  1034. % it returns the starting part (with a case change) even if there is no number.
  1035. % This is used at the beginning of a sentence.
  1036. FUNCTION {format.tr.number}
  1037. { type empty$
  1038.     { "Technical Report" }
  1039.     'type
  1040.   if$
  1041.   number empty$
  1042.     { "t" change.case$ }
  1043.     { number tie.or.space.connect }
  1044.   if$
  1045. }
  1046. % Now come the cross-referencing functions (these are invoked because
  1047. % one entry in the database file(s) cross-references another, by giving
  1048. % the other entry's database key in a `crossref' field).  This feature
  1049. % allows one or more titled things that are part of a larger titled
  1050. % thing to cross-reference the larger thing.  These styles allow for
  1051. % five posibilities: (1) an ARTICLE may cross-reference an ARTICLE;
  1052. % (2) a BOOK, (3) INBOOK, or (4) INCOLLECTION may cross-reference a BOOK;
  1053. % or (5) an INPROCEEDINGS may cross-reference a PROCEEDINGS.
  1054. % Each of these is explained in more detail later.
  1055. %
  1056. % An ARTICLE entry type may cross reference another ARTICLE (this is
  1057. % intended for when an entire journal is devoted to a single topic---
  1058. % but since there is no JOURNAL entry type, the journal, too, should be
  1059. % classified as an ARTICLE but without the author and title fields).
  1060. % This will result in two warning messages for the journal's entry
  1061. % if it's included in the reference list, but such is life.
  1062. %
  1063. % format.article.crossref ==
  1064. %  BEGIN
  1065. %    if empty$(key) then
  1066. %        if empty$(journal) then
  1067. %        warning$("need key or journal for " * cite$ *
  1068. %                        " to crossref " * crossref)
  1069. %        return(" \cite{" * crossref * "}")
  1070. %        else
  1071. %        return("In " * emphazise.correct (journal) *
  1072. %                        " \cite{" * crossref * "}")
  1073. %        fi
  1074. %    else
  1075. %        return("In " * key * " \cite{" * crossref * "}")
  1076. %    fi
  1077. %  END
  1078. %
  1079. % The other cross-referencing functions are similar, so no "comment version"
  1080. % will be given for them.
  1081. FUNCTION {format.article.crossref}
  1082. { key empty$
  1083.     { journal empty$
  1084.     { "need key or journal for " cite$ * " to crossref " * crossref *
  1085.       warning$
  1086.       ""
  1087.     }
  1088.     { "In " journal * }
  1089.       if$
  1090.     }
  1091.     { "In " key * }
  1092.   if$
  1093.   " \cite{" * crossref * "}" *
  1094. }
  1095. % We use just the last names of editors for a cross reference: either
  1096. % "editor", or "editor1 and editor2", or "editor1 et~al." depending on
  1097. % whether there are one, or two, or more than two editors.
  1098. FUNCTION {format.crossref.editor}
  1099. { editor #1 "{vv~}{ll}" format.name$
  1100.   editor num.names$ duplicate$
  1101.   #2 >
  1102.     { pop$ " et~al." * }
  1103.     { #2 <
  1104.     'skip$
  1105.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1106.         { " et~al." * }
  1107.         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  1108.       if$
  1109.     }
  1110.       if$
  1111.     }
  1112.   if$
  1113. }
  1114. % A BOOK (or INBOOK) entry type (assumed to be for a single volume in a
  1115. % multivolume work) may cross reference another BOOK (the entire multivolume).
  1116. % Usually there will be an editor, in which case we use that to construct the
  1117. % cross reference; otherwise we use a nonempty key field or else the series
  1118. % field (since the series gives the title of the multivolume work).
  1119. FUNCTION {format.book.crossref}
  1120. { volume empty$
  1121.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  1122.       "In "
  1123.     }
  1124.     { "Volume" volume tie.or.space.connect
  1125.       " of " *
  1126.     }
  1127.   if$
  1128.   editor empty$
  1129.   editor field.or.null author field.or.null =
  1130.   or
  1131.     { key empty$
  1132.     { series empty$
  1133.         { "need editor, key, or series for " cite$ * " to crossref " *
  1134.           crossref * warning$
  1135.           "" *
  1136.         }
  1137.         { "{\em " * series * "\/}" * }
  1138.       if$
  1139.     }
  1140.     { key * }
  1141.       if$
  1142.     }
  1143.     { format.crossref.editor * }
  1144.   if$
  1145.   " \cite{" * crossref * "}" *
  1146. }
  1147. % An INCOLLECTION entry type may cross reference a BOOK (assumed to be the
  1148. % collection), or an INPROCEEDINGS may cross reference a PROCEEDINGS.
  1149. % Often there will be an editor, in which case we use that to construct
  1150. % the cross reference; otherwise we use a nonempty key field or else
  1151. % the booktitle field (which gives the cross-referenced work's title).
  1152. FUNCTION {format.incoll.inproc.crossref}
  1153. { editor empty$
  1154.   editor field.or.null author field.or.null =
  1155.   or
  1156.     { key empty$
  1157.     { booktitle empty$
  1158.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  1159.           crossref * warning$
  1160.           ""
  1161.         }
  1162.         { "In {\em " booktitle * "\/}" * }
  1163.       if$
  1164.     }
  1165.     { "In " key * }
  1166.       if$
  1167.     }
  1168.     { "In " format.crossref.editor * }
  1169.   if$
  1170.   " \cite{" * crossref * "}" *
  1171. }
  1172. % Now we define the type functions for all entry types that may appear
  1173. % in the .BIB file---e.g., functions like `article' and `book'.  These
  1174. % are the routines that actually generate the .BBL-file output for
  1175. % the entry.  These must all precede the READ command.  In addition, the
  1176. % style designer should have a function `default.type' for unknown types.
  1177. % Note: The fields (within each list) are listed in order of appearance,
  1178. % except as described for an `inbook' or a `proceedings'.
  1179. %
  1180. % The article function is for an article in a journal.  An article may
  1181. % CROSSREF another article.
  1182. %    Required fields: author, title, journal, year
  1183. %    Optional fields: volume, number, pages, month, note
  1184. %
  1185. % article ==
  1186. %  BEGIN
  1187. %    output.bibitem
  1188. %    output.check(format.authors,"author")
  1189. %    new.block
  1190. %    output.check(format.title,"title")
  1191. %    new.block
  1192. %    if missing$(crossref) then
  1193. %        output.check(emphasize(journal),"journal")
  1194. %        output(format.vol.num.pages)
  1195. %        output.check(format.date,"year")
  1196. %       else
  1197. %        output.nonnull(format.article.crossref)
  1198. %        output(format.pages)
  1199. %    fi
  1200. %    new.block
  1201. %    output(note)
  1202. %    fin.entry
  1203. %  END
  1204. %
  1205. % The book function is for a whole book.  A book may CROSSREF another book.
  1206. %    Required fields: author or editor, title, publisher, year
  1207. %    Optional fields: volume or number, series, address, edition, month,
  1208. %            note
  1209. %
  1210. % book ==
  1211. %  BEGIN
  1212. %    if empty$(author) then output.check(format.editors,"author and editor")
  1213. %    else    output.check(format.authors,"author")
  1214. %        if missing$(crossref) then
  1215. %            either.or.check("author and editor",editor)
  1216. %        fi
  1217. %    fi
  1218. %    new.block
  1219. %    output.check(format.btitle,"title")
  1220. %    if missing$(crossref) then
  1221. %        output(format.bvolume)
  1222. %        new.block
  1223. %        output(format.number.series)
  1224. %        new.sentence
  1225. %        output.check(publisher,"publisher")
  1226. %        output(address)
  1227. %       else
  1228. %        new.block
  1229. %        output.nonnull(format.book.crossref)
  1230. %    fi
  1231. %    output(format.edition)
  1232. %    output.check(format.date,"year")
  1233. %    new.block
  1234. %    output(note)
  1235. %    fin.entry
  1236. %  END
  1237. %
  1238. % The other entry functions are all quite similar, so no "comment version"
  1239. % will be given for them.
  1240. FUNCTION {article}
  1241. { output.bibitem
  1242.   format.authors "author" output.check
  1243.   new.block
  1244.   crossref missing$
  1245.     { journal field.or.null
  1246.       format.vol.num.pages output
  1247.     }
  1248.     { format.article.crossref output.nonnull
  1249.       format.pages output
  1250.     }
  1251.   if$
  1252.   new.block
  1253.   note output
  1254.   fin.entry
  1255. }
  1256. FUNCTION {book}
  1257. { output.bibitem
  1258.   author empty$
  1259.     { format.editors "author and editor" output.check }
  1260.     { format.authors output.nonnull
  1261.       crossref missing$
  1262.     { "author and editor" editor either.or.check }
  1263.     'skip$
  1264.       if$
  1265.     }
  1266.   if$
  1267.   new.block
  1268.   format.btitle "title" output.check
  1269.   crossref missing$
  1270.     { format.bvolume output
  1271.       new.block
  1272.       format.number.series output
  1273.       new.sentence
  1274.       publisher "publisher" output.check
  1275.       address output
  1276.     }
  1277.     { new.block
  1278.       format.book.crossref output.nonnull
  1279.     }
  1280.   if$
  1281.   format.edition output
  1282.   format.date "year" output.check
  1283.   new.block
  1284.   note output
  1285.   fin.entry
  1286. }
  1287. % A booklet is a bound thing without a publisher or sponsoring institution.
  1288. %    Required: title
  1289. %    Optional: author, howpublished, address, month, year, note
  1290. FUNCTION {booklet}
  1291. { output.bibitem
  1292.   format.authors output
  1293.   new.block
  1294.   format.title "title" output.check
  1295.   howpublished address new.block.checkb
  1296.   howpublished output
  1297.   address output
  1298.   format.date output
  1299.   new.block
  1300.   note output
  1301.   fin.entry
  1302. }
  1303. % For the conference entry type, see inproceedings.
  1304. % An inbook is a piece of a book: either a chapter and/or a page range.
  1305. % It may CROSSREF a book.  If there's no volume field, the type field
  1306. % will come before number and series.
  1307. %    Required: author or editor, title, chapter and/or pages, publisher,year
  1308. %    Optional: volume or number, series, type, address, edition, month, note
  1309. FUNCTION {inbook}
  1310. { output.bibitem
  1311.   author empty$
  1312.     { format.editors "author and editor" output.check }
  1313.     { format.authors output.nonnull
  1314.       crossref missing$
  1315.     { "author and editor" editor either.or.check }
  1316.     'skip$
  1317.       if$
  1318.     }
  1319.   if$
  1320.   new.block
  1321.   format.btitle "title" output.check
  1322.   crossref missing$
  1323.     { format.bvolume output
  1324.       format.chapter.pages "chapter and pages" output.check
  1325.       new.block
  1326.       format.number.series output
  1327.       new.sentence
  1328.       publisher "publisher" output.check
  1329.       address output
  1330.     }
  1331.     { format.chapter.pages "chapter and pages" output.check
  1332.       new.block
  1333.       format.book.crossref output.nonnull
  1334.     }
  1335.   if$
  1336.   format.edition output
  1337.   format.date "year" output.check
  1338.   new.block
  1339.   note output
  1340.   fin.entry
  1341. }
  1342. % An incollection is like inbook, but where there is a separate title
  1343. % for the referenced thing (and perhaps an editor for the whole).
  1344. % An incollection may CROSSREF a book.
  1345. %    Required: author, title, booktitle, publisher, year
  1346. %    Optional: editor, volume or number, series, type, chapter, pages,
  1347. %            address, edition, month, note
  1348. FUNCTION {incollection}
  1349. { output.bibitem
  1350.   format.authors "author" output.check
  1351.   new.block
  1352.   format.title "title" output.check
  1353.   new.block
  1354.   crossref missing$
  1355.     { format.in.ed.booktitle "booktitle" output.check
  1356.       format.bvolume output
  1357.       format.number.series output
  1358.       format.chapter.pages output
  1359.       new.sentence
  1360.       publisher "publisher" output.check
  1361.       address output
  1362.       format.edition output
  1363.       format.date "year" output.check
  1364.     }
  1365.     { format.incoll.inproc.crossref output.nonnull
  1366.       format.chapter.pages output
  1367.     }
  1368.   if$
  1369.   new.block
  1370.   note output
  1371.   fin.entry
  1372. }
  1373. % An inproceedings is an article in a conference proceedings, and it may
  1374. % CROSSREF a proceedings.  If there's no address field, the month (& year)
  1375. % will appear just before note.
  1376. %    Required: author, title, booktitle, year
  1377. %    Optional: editor, volume or number, series, pages, address, month,
  1378. %            organization, publisher, note
  1379. FUNCTION {inproceedings}
  1380. { output.bibitem
  1381.   format.authors "author" output.check
  1382.   new.block
  1383.   format.title "title" output.check
  1384.   new.block
  1385.   crossref missing$
  1386.     { format.in.ed.booktitle "booktitle" output.check
  1387.       format.bvolume output
  1388.       format.number.series output
  1389.       format.pages output
  1390.       address empty$
  1391.     { organization publisher new.sentence.checkb
  1392.       organization output
  1393.       publisher output
  1394.       format.date "year" output.check
  1395.     }
  1396.     { address output.nonnull
  1397.       format.date "year" output.check
  1398.       new.sentence
  1399.       organization output
  1400.       publisher output
  1401.     }
  1402.       if$
  1403.     }
  1404.     { format.incoll.inproc.crossref output.nonnull
  1405.       format.pages output
  1406.     }
  1407.   if$
  1408.   new.block
  1409.   note output
  1410.   fin.entry
  1411. }
  1412. % The conference function is included for Scribe compatibility.
  1413. FUNCTION {conference} { inproceedings }
  1414. % A manual is technical documentation.
  1415. %    Required: title
  1416. %    Optional: author, organization, address, edition, month, year, note
  1417. FUNCTION {manual}
  1418. { output.bibitem
  1419.   author empty$
  1420.     { organization empty$
  1421.     'skip$
  1422.     { organization output.nonnull
  1423.       address output
  1424.     }
  1425.       if$
  1426.     }
  1427.     { format.authors output.nonnull }
  1428.   if$
  1429.   new.block
  1430.   format.btitle "title" output.check
  1431.   author empty$
  1432.     { organization empty$
  1433.     { address new.block.checka
  1434.       address output
  1435.     }
  1436.     'skip$
  1437.       if$
  1438.     }
  1439.     { organization address new.block.checkb
  1440.       organization output
  1441.       address output
  1442.     }
  1443.   if$
  1444.   format.edition output
  1445.   format.date output
  1446.   new.block
  1447.   note output
  1448.   fin.entry
  1449. }
  1450. % A mastersthesis is a Master's thesis.
  1451. %    Required: author, title, school, year
  1452. %    Optional: type, address, month, note
  1453. FUNCTION {mastersthesis}
  1454. { output.bibitem
  1455.   format.authors "author" output.check
  1456.   new.block
  1457.   format.title "title" output.check
  1458.   new.block
  1459.   "Master's thesis" format.thesis.type output.nonnull
  1460.   school "school" output.check
  1461.   address output
  1462.   format.date "year" output.check
  1463.   new.block
  1464.   note output
  1465.   fin.entry
  1466. }
  1467. % A misc is something that doesn't fit elsewhere.
  1468. %    Required: at least one of the `optional' fields
  1469. %    Optional: author, title, howpublished, month, year, note
  1470. FUNCTION {misc}
  1471. { output.bibitem
  1472.   format.authors output
  1473.   title howpublished new.block.checkb
  1474.   format.title output
  1475.   howpublished new.block.checka
  1476.   howpublished output
  1477.   format.date output
  1478.   new.block
  1479.   note output
  1480.   fin.entry
  1481.   empty.misc.check
  1482. }
  1483. % A phdthesis is like a mastersthesis.
  1484. %    Required: author, title, school, year
  1485. %    Optional: type, address, month, note
  1486. FUNCTION {phdthesis}
  1487. { output.bibitem
  1488.   format.authors "author" output.check
  1489.   new.block
  1490.   format.btitle "title" output.check
  1491.   new.block
  1492.   "PhD thesis" format.thesis.type output.nonnull
  1493.   school "school" output.check
  1494.   address output
  1495.   format.date "year" output.check
  1496.   new.block
  1497.   note output
  1498.   fin.entry
  1499. }
  1500. % A proceedings is a conference proceedings.
  1501. % If there is an organization but no editor field, the organization will
  1502. % appear as the first optional field (we try to make the first block nonempty);
  1503. % if there's no address field, the month (& year) will appear just before note.
  1504. %    Required: title, year
  1505. %    Optional: editor, volume or number, series, address, month,
  1506. %            organization, publisher, note
  1507. FUNCTION {proceedings}
  1508. { output.bibitem
  1509.   editor empty$
  1510.     { organization output }
  1511.     { format.editors output.nonnull }
  1512.   if$
  1513.   new.block
  1514.   format.btitle "title" output.check
  1515.   format.bvolume output
  1516.   format.number.series output
  1517.   address empty$
  1518.     { editor empty$
  1519.     { publisher new.sentence.checka }
  1520.     { organization publisher new.sentence.checkb
  1521.       organization output
  1522.     }
  1523.       if$
  1524.       publisher output
  1525.       format.date "year" output.check
  1526.     }
  1527.     { address output.nonnull
  1528.       format.date "year" output.check
  1529.       new.sentence
  1530.       editor empty$
  1531.     'skip$
  1532.     { organization output }
  1533.       if$
  1534.       publisher output
  1535.     }
  1536.   if$
  1537.   new.block
  1538.   note output
  1539.   fin.entry
  1540. }
  1541. % A techreport is a technical report.
  1542. %    Required: author, title, institution, year
  1543. %    Optional: type, number, address, month, note
  1544. FUNCTION {techreport}
  1545. { output.bibitem
  1546.   format.authors "author" output.check
  1547.   new.block
  1548.   format.title "title" output.check
  1549.   new.block
  1550.   format.tr.number output.nonnull
  1551.   institution "institution" output.check
  1552.   address output
  1553.   format.date "year" output.check
  1554.   new.block
  1555.   note output
  1556.   fin.entry
  1557. }
  1558. % An unpublished is something that hasn't been published.
  1559. %    Required: author, title, note
  1560. %    Optional: month, year
  1561. FUNCTION {unpublished}
  1562. { output.bibitem
  1563.   format.authors "author" output.check
  1564.   new.block
  1565.   format.title "title" output.check
  1566.   new.block
  1567.   note "note" output.check
  1568.   format.date output
  1569.   fin.entry
  1570. }
  1571. % We use entry type `misc' for an unknown type; BibTeX gives a warning.
  1572. FUNCTION {default.type} { misc }
  1573. % Here are macros for common things that may vary from style to style.
  1574. % Users are encouraged to use these macros.
  1575. %
  1576. % Months are either written out in full or abbreviated
  1577. MACRO {jan} {"Jan."}
  1578. MACRO {feb} {"Feb."}
  1579. MACRO {mar} {"Mar."}
  1580. MACRO {apr} {"Apr."}
  1581. MACRO {may} {"May"}
  1582. MACRO {jun} {"June"}
  1583. MACRO {jul} {"July"}
  1584. MACRO {aug} {"Aug."}
  1585. MACRO {sep} {"Sept."}
  1586. MACRO {oct} {"Oct."}
  1587. MACRO {nov} {"Nov."}
  1588. MACRO {dec} {"Dec."}
  1589. % Journals are either written out in full or abbreviated;
  1590. % the abbreviations are like those found in ACM publications.
  1591. %
  1592. % To get a completely different set of abbreviations, it may be best to make
  1593. % a separate .bib file with nothing but those abbreviations; users could then
  1594. % include that file name as the first argument to the \bibliography command
  1595. MACRO {acmcs} {"ACM Comput. Surv."}
  1596. MACRO {acta} {"Acta Inf."}
  1597. MACRO {cacm} {"Commun. ACM"}
  1598. MACRO {ibmjrd} {"IBM J. Res. Dev."}
  1599. MACRO {ibmsj} {"IBM Syst.~J."}
  1600. MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  1601. MACRO {ieeetc} {"IEEE Trans. Comput."}
  1602. MACRO {ieeetcad}
  1603.  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  1604. MACRO {ipl} {"Inf. Process. Lett."}
  1605. MACRO {jacm} {"J.~ACM"}
  1606. MACRO {jcss} {"J.~Comput. Syst. Sci."}
  1607. MACRO {scp} {"Sci. Comput. Programming"}
  1608. MACRO {sicomp} {"SIAM J. Comput."}
  1609. MACRO {tocs} {"ACM Trans. Comput. Syst."}
  1610. MACRO {tods} {"ACM Trans. Database Syst."}
  1611. MACRO {tog} {"ACM Trans. Gr."}
  1612. MACRO {toms} {"ACM Trans. Math. Softw."}
  1613. MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  1614. MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  1615. MACRO {tcs} {"Theoretical Comput. Sci."}
  1616. %% /usr/local/lib/tex/bibtex/phyjfull.btx, Tue Jun 30 08:37:48 1992
  1617. %% Edit by Nelson H. F. Beebe <beebe@alfred.math.utah.edu>
  1618. %% Change file names in leading comment
  1619. % Journal Title Abbreviations from the Physical Review Style and Notation
  1620. %    Guide, July, 1983, in BAPS Vol. 28.
  1621. %  Selected by Cris Barnes and Charles Karney, March 1988
  1622. % IMPORTANT!! Don't make changes to this file without making the
  1623. %           corresponding changes to
  1624. %            phyjabb.bib
  1625. %            phyjabb.btx
  1626. MACRO {advp} {"Advances in Physics"}
  1627. MACRO {ajp} {"American Journal of Physics"}
  1628. MACRO {ao} {"Applied Optics"}
  1629. MACRO {apl} {"Applied Physics Letters"}
  1630. MACRO {apj} {"Astrophysical Journal"}
  1631. MACRO {baps} {"Bulletin of the American Physical Society"}
  1632. MACRO {cpc} {"Computer Physics Communications"}
  1633. MACRO {cppcf} {"Comments on Plasma Physics and Controlled Fusion"}
  1634. MACRO {fed} {"Fusion Engineering and Design"}
  1635. MACRO {ft} {"Fusion Technology"}
  1636. MACRO {ieeens} {"IEEE Transactions on Nuclear Science"}
  1637. MACRO {ieeeps} {"IEEE Transactions on Plasma Science"}
  1638. MACRO {ijimw} {"International Journal of Infrared and Millimeter Waves"}
  1639. MACRO {ip} {"Infrared Physics"}
  1640. MACRO {jap} {"Journal of Applied Physics"}
  1641. MACRO {jcp} {"Journal of Computational Physics"}
  1642. MACRO {jetp} {"Soviet Physics-JETP"}
  1643. MACRO {jfe} {"Journal of Fusion Energy"}
  1644. MACRO {jfm} {"Journal of Fluid Mechanics"}
  1645. MACRO {jgr} {"Journal of Geophysical Research"}
  1646. MACRO {jmp} {"Journal of Mathematical Physics"}
  1647. MACRO {jne} {"Journal of Nuclear Energy"}
  1648. MACRO {jnec} {"Journal of Nuclear Energy, Part C: Plasma Physics, Accelerators, Thermonuclear Research"}
  1649. MACRO {jnm} {"Journal of Nuclear Materials"}
  1650. MACRO {josa} {"Journal of the Optical Society of America"}
  1651. MACRO {jpp} {"Journal of Plasma Physics"}
  1652. MACRO {jpsj} {"Journal of the Physical Society of Japan"}
  1653. MACRO {jvst} {"Journal of Vacuum Science and Technology"}
  1654. MACRO {nedf} {"Nuclear Engineering and Design/Fusion"}
  1655. MACRO {nf} {"Nuclear Fusion"}
  1656. MACRO {nim} {"Nuclear Instruments and Methods"}
  1657. MACRO {nimpr} {"Nuclear Instruments and Methods in Physics Research"}
  1658. MACRO {nt/f} {"Nuclear Technology/Fusion"}
  1659. MACRO {pf} {"Physics of Fluids"}
  1660. MACRO {pfa} {"Physics of Fluids A: Fluid Dynamics"}
  1661. MACRO {pfb} {"Physics of Fluids B: Plasma Physics"}
  1662. MACRO {pl} {"Physics Letters"}
  1663. MACRO {pla} {"Physics Letters A"}
  1664. MACRO {pnas} {"Proceedings of the National Academy of Sciences of the USA"}
  1665. MACRO {pp} {"Plasma Physics"}
  1666. MACRO {ppcf} {"Plasma Physics and Controlled Fusion"}
  1667. MACRO {prl} {"Physical Review Letters"}
  1668. MACRO {pr} {"Physical Review"}
  1669. MACRO {pra} {"Physical Review A: General Physics"}
  1670. MACRO {ps} {"Physica Scripta"}
  1671. MACRO {rmp} {"Reviews of Modern Physics"}
  1672. MACRO {rsi} {"Review of Scientific Instruments"}
  1673. MACRO {sjpp} {"Soviet Journal of Plasma Phys."}
  1674. MACRO {spd} {"Soviet Physics-Doklady"}
  1675. MACRO {sptp} {"Soviet Physics-Technical Physics"}
  1676. MACRO {spu} {"Soviet Physics-Uspeki"}
  1677. % Now we read in the .BIB entries.
  1678. READ
  1679. % The sortify function converts to lower case after purify$ing; it's
  1680. % used in sorting and in computing alphabetic labels after sorting
  1681. %
  1682. % The chop.word(w,len,s) function returns either s or, if the first len
  1683. % letters of s equals w (this comparison is done in the third line of the
  1684. % function's definition), it returns that part of s after w.
  1685. % This long comment applies only to alphabetic labels
  1686. %
  1687. % The format.lab.names function makes a short label by using the initials of
  1688. % the von and Last parts of the names (but if there are more than four names,
  1689. % (i.e., people) it truncates after three and adds a superscripted "+";
  1690. % it also adds such a "+" if the last of multiple authors is "others").
  1691. % If there is only one name, and its von and Last parts combined have just
  1692. % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
  1693. % we take the first three letters of the last name.  The boolean
  1694. % et.al.char.used tells whether we've used a superscripted "+", so that we
  1695. % know whether to include a LaTeX macro for it.
  1696. %
  1697. % format.lab.names(s) ==
  1698. %  BEGIN
  1699. %    numnames := num.names$(s)
  1700. %    if numnames > 1 then
  1701. %        if numnames > 4 then
  1702. %        namesleft := 3
  1703. %        else
  1704. %        namesleft := numnames
  1705. %        nameptr := 1
  1706. %        nameresult := ""
  1707. %        while namesleft > 0
  1708. %          do
  1709. %        if (name_ptr = numnames) and
  1710. %             format.name$(s, nameptr, "{ff }{vv }{ll}{ jj}") = "others"
  1711. %           then nameresult := nameresult * "{\etalchar{+}}"
  1712. %            et.al.char.used := true
  1713. %           else nameresult := nameresult *
  1714. %                format.name$(s, nameptr, "{v{}}{l{}}")
  1715. %        nameptr := nameptr + 1
  1716. %        namesleft := namesleft - 1
  1717. %          od
  1718. %        if numnames > 4 then
  1719. %        nameresult := nameresult * "{\etalchar{+}}"
  1720. %        et.al.char.used := true
  1721. %    else
  1722. %        t := format.name$(s, 1, "{v{}}{l{}}")
  1723. %        if text.length$(t) < 2 then    % there's just one name-token
  1724. %        nameresult := text.prefix$(format.name$(s,1,"{ll}"),3)
  1725. %        else
  1726. %        nameresult := t
  1727. %        fi
  1728. %    fi
  1729. %    return nameresult
  1730. %  END
  1731. %
  1732. % Exactly what fields we look at in constructing the primary part of the label
  1733. % depends on the entry type; this selectivity (as opposed to, say, always
  1734. % looking at author, then editor, then key) helps ensure that "ignored" fields,
  1735. % as described in the LaTeX book, really are ignored.  Note that MISC is part
  1736. % of the deepest `else' clause in the nested part of calc.label; thus, any
  1737. % unrecognized entry type in the database is handled correctly.
  1738. %
  1739. % There is one auxiliary function for each of the four different sequences of
  1740. % fields we use.  The first of these functions looks at the author field, and
  1741. % then, if necessary, the key field.  The other three functions, which might
  1742. % look at two fields and the key field, are similar, except that the key field
  1743. % takes precedence over the organization field (for labels---not for sorting).
  1744. %
  1745. % The calc.label function calculates the preliminary label of an entry, which
  1746. % is formed by taking three letters of information from the author or editor or
  1747. % key or organization field (depending on the entry type and on what's empty,
  1748. % but ignoring a leading "The " in the organization), and appending the last
  1749. % two characters (digits) of the year. It is an error if the appropriate fields
  1750. % among author, editor, organization, and key are missing, and we use
  1751. % the first three letters of the cite$ in desperation when this happens.
  1752. % The resulting label has the year part, but not the name part, purify$ed
  1753. % (purify$ing the year allows some sorting shenanigans by the user).
  1754. %
  1755. % This function also calculates the version of the label to be used in sorting.
  1756. %
  1757. % The final label may need a trailing 'a', 'b', etc., to distinguish it from
  1758. % otherwise identical labels, but we can't calculated those "extra.label"s
  1759. % until after sorting.
  1760. %
  1761. % calc.label ==
  1762. %  BEGIN
  1763. %    if type$ = "book" or "inbook" then
  1764. %        author.editor.key.label
  1765. %    else if type$ = "proceedings" then
  1766. %        editor.key.organization.label
  1767. %    else if type$ = "manual" then
  1768. %        author.key.organization.label
  1769. %    else
  1770. %        author.key.label
  1771. %    fi fi fi
  1772. %    label := label * substring$(purify$(field.or.null(year)), -1, 2)
  1773. %        % assuming we will also sort, we calculate a sort.label
  1774. %    sort.label := sortify(label), but use the last four, not two, digits
  1775. %  END
  1776. % When sorting, we compute the sortkey by executing "presort" on each entry.
  1777. % The presort key contains a number of "sortify"ed strings, concatenated
  1778. % with multiple blanks between them.  This makes things like "brinch  per"
  1779. % come before "brinch hansen  per".
  1780. %
  1781. % The fields used here are: the sort.label for alphabetic labels (as set by
  1782. % calc.label), followed by the author names (or editor names or organization
  1783. % (with a leading "The " removed) or key field, depending on entry type and on
  1784. % what's empty), followed by year, followed by the first bit of the title
  1785. % (chopping off a leading "The ", "A ", or "An ").
  1786. % Names are formatted: Von Last First Junior.
  1787. % The names within a part will be separated by a single blank
  1788. % (such as "brinch hansen"), two will separate the name parts themselves
  1789. % (except the von and last), three will separate the names,
  1790. % four will separate the names from year (and from label, if alphabetic),
  1791. % and four will separate year from title.
  1792. %
  1793. % The sort.format.names function takes an argument that should be in
  1794. % BibTeX name format, and returns a string containing "   "-separated
  1795. % names in the format described above.  The function is almost the same
  1796. % as format.names.
  1797. % This long comment applies only to alphabetic labels, when sorted
  1798. %
  1799. % Now comes the final computation for alphabetic labels, putting in the 'a's
  1800. % and 'b's and so forth if required.  This involves two passes: a forward
  1801. % pass to put in the 'b's, 'c's and so on, and a backwards pass
  1802. % to put in the 'a's (we don't want to put in 'a's unless we know there
  1803. % are 'b's).
  1804. % We have to keep track of the longest (in width$ terms) label, for use
  1805. % by the "thebibliography" environment.
  1806. %
  1807. % VAR: longest.label, last.sort.label, next.extra: string
  1808. %      longest.label.width, last.extra.num: integer
  1809. %
  1810. % initialize.longest.label ==
  1811. %  BEGIN
  1812. %    longest.label := ""
  1813. %    last.sort.label := int.to.chr$(0)
  1814. %    next.extra := ""
  1815. %    longest.label.width := 0
  1816. %    last.extra.num := 0
  1817. %  END
  1818. %
  1819. % forward.pass ==
  1820. %  BEGIN
  1821. %    if last.sort.label = sort.label then
  1822. %        last.extra.num := last.extra.num + 1
  1823. %        extra.label := int.to.chr$(last.extra.num)
  1824. %    else
  1825. %        last.extra.num := chr.to.int$("a")
  1826. %        extra.label := ""
  1827. %        last.sort.label := sort.label
  1828. %    fi
  1829. %  END
  1830. %
  1831. % reverse.pass ==
  1832. %  BEGIN
  1833. %    if next.extra = "b" then
  1834. %        extra.label := "a"
  1835. %    fi
  1836. %    label := label * extra.label
  1837. %    if width$(label) > longest.label.width then
  1838. %        longest.label := label
  1839. %        longest.label.width := width$(label)
  1840. %    fi
  1841. %    next.extra := extra.label
  1842. %  END
  1843. % Now comes the computation for numeric labels.
  1844. % We use either the sorted order or original order.
  1845. % We still have to keep track of the longest (in width$ terms) label, for use
  1846. % by the "thebibliography" environment.
  1847. STRINGS { longest.label }
  1848. INTEGERS { number.label longest.label.width }
  1849. FUNCTION {initialize.longest.label}
  1850. { "" 'longest.label :=
  1851.   #1 'number.label :=
  1852.   #0 'longest.label.width :=
  1853. }
  1854. FUNCTION {longest.label.pass}
  1855. { number.label int.to.str$ 'label :=
  1856.   number.label #1 + 'number.label :=
  1857.   label width$ longest.label.width >
  1858.     { label 'longest.label :=
  1859.       label width$ 'longest.label.width :=
  1860.     }
  1861.     'skip$
  1862.   if$
  1863. }
  1864. EXECUTE {initialize.longest.label}
  1865. ITERATE {longest.label.pass}
  1866. % Now we're ready to start writing the .BBL file.
  1867. % We begin, if necessary, with a LaTeX macro for unnamed names in an alphabetic
  1868. % label; next comes stuff from the `preamble' command in the database files.
  1869. % Then we give an incantation containing the command
  1870. %     \begin{thebibliography}{...}
  1871. % where the `...' is the longest label.
  1872. %
  1873. % We also call init.state.consts, for use by the output routines.
  1874. FUNCTION {begin.bib}
  1875. { preamble$ empty$
  1876.     'skip$
  1877.     { preamble$ write$ newline$ }
  1878.   if$
  1879.   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  1880. }
  1881. EXECUTE {begin.bib}
  1882. EXECUTE {init.state.consts}
  1883. % Now we produce the output for all the entries
  1884. ITERATE {call.type$}
  1885. % Finally, we finish up by writing the `\end{thebibliography}' command.
  1886. FUNCTION {end.bib}
  1887. { newline$
  1888.   "\end{thebibliography}" write$ newline$
  1889. }
  1890. EXECUTE {end.bib}
  1891.